#include "Metro.h"

#include <iostream>
#include <ctime>	// Pour time()


void TestChargerMetro();
void TestDijkstra();
void TestBellmanFord();
void TestAlgorithmeAstar();
void TestEstAccessibleMetro();
void TestCheminLePlusLongMetro();
void TestFermerStationMetro();

int main(){
	TestChargerMetro();
	::system("pause");
	std::cout << "\n\n\n";
	TestDijkstra();
	::system("pause");
	std::cout << "\n\n\n";
	TestBellmanFord();
	::system("pause");
	std::cout << "\n\n\n";
	TestAlgorithmeAstar();
	::system("pause");
	std::cout << "\n\n\n";
	TestCheminLePlusLongMetro();
	::system("pause");
	std::cout << "\n\n\n";
	TestEstAccessibleMetro();
	::system("pause");
	std::cout << "\n\n\n";
	TestFermerStationMetro();
	std::cout << "\n\n\n";
	::system("pause");
}

//*****************************************************************************
// Test de la methode: 
//    Metro:: Metro(std::ifstream &f)
//*****************************************************************************
void TestChargerMetro(){
	std::ifstream infile;
	infile.open ("Metro.txt", std::ifstream::in);
	Metro m(infile);

	m.afficherStations();
}

//*****************************************************************************
// Test de la methode: 
//    std::vector<std::string> Metro::determinerMinParcours(const std::string & origine, const std::string & destination, int & nbSec)
//*****************************************************************************
void TestDijkstra(){
	std::ifstream infile;
	infile.open ("Metro.txt", std::ifstream::in);
	Metro m(infile);

	clock_t c1, c2;
	int cout;
	c1= clock();
	m.afficherStations(m.determinerMinParcours("Vavin", "Danube", cout));
	c2= clock();
	std::cout << "Cout de dijkstra : " << cout << "\n";
	std::cout << "Temps d'execution : " << (long)(c2-c1) << "\n";
}

//*****************************************************************************
// Test de la methode: 
//    std::vector<std::string> Metro::bellManFord(const std::string & origine, const std::string & destination, int & nbSec)
//*****************************************************************************
void TestBellmanFord(){
	std::ifstream infile;
	infile.open ("Metro.txt", std::ifstream::in);
	Metro m(infile);

	clock_t c1, c2;
	int cout;
	c1= clock();
	m.afficherStations(m.bellManFord("Vavin", "Danube", cout));
	c2= clock();
	std::cout << "Cout de Bellman-Ford : " << cout << "\n";
	std::cout << "Temps d'execution : " << (long)(c2-c1) << "\n";
}

//*****************************************************************************
// Test de la methode: 
//    std::vector<std::string> Metro::algorithmeAstar(const std::string & origine, const std::string & destination, int & nbSec)
//*****************************************************************************
void TestAlgorithmeAstar(){
	std::ifstream infile;
	infile.open ("Metro.txt", std::ifstream::in);
	Metro m(infile);

	clock_t c1, c2;
	int cout;
	c1= clock();
	m.afficherStations(m.algorithmeAstar("Vavin", "Danube", cout));
	c2= clock();
	std::cout << "Cout de A* : " << cout << "\n";
	std::cout << "Temps d'execution : " << (long)(c2-c1) << "\n";
}

//*****************************************************************************
// Test de la methode: 
//    bool Metro::estAccessibleMetro(std::vector< std::vector<std::string> > &tab)
//*****************************************************************************
void TestEstAccessibleMetro(){
	std::ifstream infile;
	infile.open ("Metro.txt", std::ifstream::in);
	Metro m(infile);

	clock_t c1, c2;
	c1= clock();

	std::vector<std::vector<std::string>> v;
	std::cout << "EstAccessibleMetro : " << m.estAccessibleMetro(v) << "\n";
	c2= clock();

	for (int i = 0; i < v.size(); i++){
		std::cout << "Composantes " << (i+1) << " :\n";
		m.afficherStations(v.at(i));
	}
	std::cout << "Temps d'execution : " << (long)(c2-c1) << "\n";
}

//*****************************************************************************
// Test de la methode: 
//    std::vector<std::string> Metro::cheminLePlusLongMetro(const std::string& origine, const std::string& destination, int &cout)
//*****************************************************************************
void TestCheminLePlusLongMetro(){
	std::ifstream infile;
	infile.open ("Metro.txt", std::ifstream::in);
	Metro m(infile);

	int cout;
	m.afficherStations(m.cheminLePlusLongMetro("Vavin", "Danube", cout));
	std::cout << "Cout de A* Inverse : " << cout << "\n";
}

//*****************************************************************************
// Test de la methode: 
//    std::vector<std::string> Metro::fermerStationMetro()
//*****************************************************************************
void TestFermerStationMetro(){
	std::ifstream infile;
	infile.open ("Metro.txt", std::ifstream::in);
	Metro m(infile);

	clock_t c1, c2;
	c1= clock();

	std::vector<std::string> v = m.fermerStationMetro();

	c2= clock();

	std::cout << "Points d'articulations :\n";
	m.afficherStations(v);
	std::cout << "Temps d'execution : " << (long)(c2-c1) << "\n";
	
}
